package tk.heimashuma.store.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;

import javax.naming.Name;
import javax.persistence.*;
import java.io.Serializable;
import java.util.List;

/**
 * 用户的实体类
 */
@Entity
@Data
@Table(name = "users",
        uniqueConstraints = {@UniqueConstraint(columnNames = {"iphone","email"})},
        indexes = {@Index(columnList = "username",name = "index_username"),
                    @Index(columnList = "password",name = "index_password")
        })
@JsonIgnoreProperties({"password"})
public class Users implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer uid;
    @Column(length = 30,nullable = false)
    private String username;
    @Column(length = 32,nullable = false)
    private String password;
    @Column(length = 19)
    private String iphone;
    @Column(length = 30)
    private String email;
    @Column(name = "email_code",length = 32)
    private String emailCode;
  /*  @Column(name = "iphone_code")
    private String iphoneCode;*/
    @Column(columnDefinition = "integer default '0'",length = 10)
    private Integer credits = 0;

    @OneToMany(mappedBy = "user")
    @JsonIgnoreProperties(value = {"user"})
    private List<Addrs> addrsList;
    @OneToMany(mappedBy = "user")
    @JsonIgnoreProperties(value = {"user"})
    private List<Car> carList;
    @OneToMany(mappedBy = "user")
    private List<Transaction> transactionList;

}
